/**
 * @lastUpdateBy : shan
 * @description: 可视数据目录管理
 */
import qs from 'qs';

let urlTest = 'http://192.168.2.20:9402/agcim-viewer-rest';
let   apiPath1 = {
	dirimagestore_add: urlTest + '/dirimagestore/add',
	dirimagestore_update: urlTest + '/dirimagestore/update',
	dirimagestore_deleteList: urlTest + '/dirimagestore/deleteCascadeList?',
	dirimagestore_dragSort: urlTest + '/dirimagestore/dragSort',
	dirimagestore_treeByCode: urlTest + '/dirimagestore/treeByCode',
	dirimagestore_get: urlTest + '/dirimagestore/get',
};
export default {
	/**
	 * @description: 新增数据
	 * @param {Object} params
	 * @return {Promise}
	 */
	addDirImageStore(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getDataByPost( apiPath1.dirimagestore_add, qs.stringify(params))
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},

	/**
	 * @description: 更新数据
	 * @param {Object} params
	 * @return {Promise}
	 */
	updateDirImageStore(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getDataByPost(
					 apiPath1.dirimagestore_update,
					qs.stringify(params)
				)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},

	/**
	 * 删除
	 * @param {Object} params
	 * @returns {Promise}
	 */
	deleteDirImageStore(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.delete( apiPath1.dirimagestore_deleteList, params)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},

	/**
	 * @description: 排序数据
	 * @param {Object} params
	 * @return {Promise}
	 */
	dragSortDirImageStore(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getDataByPost( apiPath1.dirimagestore_dragSort, params)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},

	/**
	 * @description: 获取数据
	 * @param {Object} params 参数
	 * @return {Promise}
	 */
	getImageStore(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getData( apiPath1.dirimagestore_treeByCode, params)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},

	/**
	 * @description: 获取数据
	 * @param {Object} params 参数
	 * @return {Promise}
	 */
	getImageList(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getData( apiPath1.dirimagestore_get, params)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},

	/**
	 * @description: 获取数据
	 * @param {Object} params 参数
	 * @return {Promise}
	 */
	selectAuthPageByDirId(params) {
		return new Promise((resolve, reject) => {
			agcim.net.axiosWraper
				.getData( apiPath1.selectAuthPageByDirId, params)
				.then(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject(response);
						}
					},
					(error) => {
						reject(error);
					}
				);
		});
	},
};
